﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Text;

public partial class cn_index : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected string GetZtactiveList(string TypeID,string  TopNum,int length)
    {
        string sql = "select top " + TopNum + " * from Whir_U_News where TypeID=" + TypeID + " order by CreateDate desc";
        string mode = "ztactive";
        if (TypeID == "67" || TypeID == "74"||TypeID=="83"||TypeID=="79")
        {
            mode = "index";
        }
        System.Text.StringBuilder sb = new StringBuilder();
        System.Data.DataTable dt = Whir.SQLServerDAL.DbHelperSQL.Query(sql).Tables[0];
        if (dt != null && dt.Rows.Count > 0)
        {
            foreach (System.Data.DataRow dr in dt.Rows)
            {
                string title = dr["Title"].ToString();
                string id = dr["Whir_U_News_PID"].ToString();
                string _TypeID = dr["TypeID"].ToString();
                sb.AppendFormat("<li><a   href=\"news_info.aspx?id={1}&mode="+mode+"&cid={2}\">" + Whir.Common.WebHelper.StringHelper.CutString(dr["Title"].ToString(), length) + "</a></li>", title, id, _TypeID);
            }
        }

        return sb.ToString();
    }


    protected string GetNewsList(string TypeID, string TopNum,int length)
    {
        string sql = "select top " + TopNum + " * from Whir_U_News where TypeID=" + TypeID + " or TypeID in (select ColumnID from Whir_Column where ParentId="+TypeID+") order by CreateDate desc";
        System.Text.StringBuilder sb = new StringBuilder();
        System.Data.DataTable dt = Whir.SQLServerDAL.DbHelperSQL.Query(sql).Tables[0];
        if (dt != null && dt.Rows.Count > 0)
        {
            foreach (System.Data.DataRow dr in dt.Rows)
            {
                string title = dr["Title"].ToString();
                string id = dr["Whir_U_News_PID"].ToString();
                string _TypeID = dr["TypeID"].ToString();
                string CreateDate=Convert.ToDateTime(dr["CreateDate"].ToString()).ToString("MM-dd");
                sb.AppendFormat("<li><span>{3}</span><a   href=\"news_info.aspx?id={1}&mode=&cid={2}\">" + Whir.Common.WebHelper.StringHelper.CutString(dr["Title"].ToString(), length) + "</a></li>", title, id, _TypeID, CreateDate);
            }
        }

        return sb.ToString();
    }


    protected string GetTopNewsList(string TypeID, string TopNum)
    {
        string str = "";
        int length=22;
        string sql = "select top " + TopNum + " * from Whir_U_News where TypeID=" + TypeID + " or TypeID in (select ColumnID from Whir_Column where ParentId=" + TypeID + ") order by CreateDate desc";
        System.Text.StringBuilder sb = new StringBuilder();
        System.Data.DataTable dt = Whir.SQLServerDAL.DbHelperSQL.Query(sql).Tables[0];
        if (dt != null && dt.Rows.Count > 0)
        {
            for(int i=0;i<dt.Rows.Count;i++)
            {
                if (i == 0)
                {
                    str = "class=\"cenbox_ul_li\"";
                    length=20;
                }
                else
                {
                    str = "";
                    length = 32;
                }
                string title = dt.Rows[i]["Title"].ToString();
                string id = dt.Rows[i]["Whir_U_News_PID"].ToString();
                string _TypeID = dt.Rows[i]["TypeID"].ToString();
                string CreateDate = Convert.ToDateTime(dt.Rows[i]["CreateDate"].ToString()).ToString("MM-dd");
                
                sb.AppendFormat("<li {4}><span>{3}</span><a   href=\"news_info.aspx?id={1}&mode=&cid={2}\">" + Whir.Common.WebHelper.StringHelper.CutString(dt.Rows[i]["Title"].ToString(), length) + "</a></li>", title, id, _TypeID, CreateDate, str);
            }
        }

        return sb.ToString();
    }

}
